
<!-- 左边导航菜单 -->
<template>
  <el-menu default-active="2" :collapse="collapsed" collapse-transition  router :default-active="$route.path" unique-opened class="el-menu-vertical-demo" background-color="#334157" text-color="#fff" active-text-color="#ffd04b">
    <div class="logobox">
      肇远数字虚拟人后台记录管理系统
    </div>
    <el-submenu v-for="menu in allmenu" :key="menu.menuid" :index="menu.menuname">
      <template slot="title">
        <span>{{menu.menuname}}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item v-for="chmenu in menu.menus" :index="'/'+chmenu.url" :key="chmenu.menuid">

          <span>{{chmenu.menuname}}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
import { menu } from '../api/userMG'
export default {
  name: 'leftnav',
  data() {
    return {
      collapsed: false,
      allmenu: []
    }
  },
  created() {
    let res = {
      success: true,
      // 右侧标题
      data: [
      {
          menuid: 1,
          icon: 'li-icon-shangchengxitongtubiaozitihuayuanwenjian91',
          menuname: '首页',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 11,
              icon: 'icon-provider-manage',
              menuname: '概览',
              hasThird: 'N',
              url: 'homePage',
              menus: null
            }
          ]
        },
        {
          menuid: 2,
          icon: 'li-icon-xiangmuguanli',
          menuname: '虚拟人管理与配置',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 22,
              icon: 'icon-cat-skuQuery',
              menuname: '虚拟人创建与定制', //提供丰富的自定义选项，满足用户个性化需求
              hasThird: 'N',
              url: 'creact/creact',
              menus: null
            },
            {
              menuid: 23,
              icon: 'icon-cat-skuQuery',
              menuname: '虚拟人交互模拟',//模拟用户与虚拟人的交互过程，便于测试与调整。
              hasThird: 'N',
              url: 'exchange/exchange',
              menus: null
            },

          ]
        },
        {
          menuid: 3,
          icon: 'li-icon-dingdanguanli',
          menuname: '交互记录与分析模块',
          hasThird: null,
          url: null,
          menus: [
          {
              menuid: 31,
              icon: 'icon-provider-manage',
              menuname: '虚拟人交互分析',
              hasThird: 'N',
              url: 'InteractionAnalysis/InteractionAnalysis',
              menus: null
            },
            {
              menuid: 32,
              icon: 'icon-order-manage',
              menuname: '交互记录',
              hasThird: 'N',
              url: 'InteractionRecords/InteractionRecords',
              menus: null
            },
          ]
        },
        {
          menuid: 4,
          icon: 'li-icon-dingdanguanli',
          menuname: '学术库管理与维护',
          hasThird: null,
          url: null,
          menus: [
          {
              menuid: 41,
              icon: 'icon-provider-manage',
              menuname: '学术库内容审核',  //学术库 列表
              hasThird: 'N',
              url: 'Auditing/Auditing',
              menus: null
            },
            {
              menuid: 42,
              icon: 'icon-provider-manage',
              menuname: '学术库问答训练', 
              hasThird: 'N',
              url: 'train/train',
              menus: null
            },
          ]
        },
        {
          menuid: 5,
          icon: 'li-icon-xitongguanli',
          menuname: '用户管理模块',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 51,
              icon: 'icon-cus-manage',
              menuname: '用户管理',
              hasThird: 'N',
              url: 'system/user',
              menus: null
            },
            {
              menuid: 52,
              icon: 'icon-news-manage',
              menuname: '角色管理',
              hasThird: 'N',
              url: 'system/Role',
              menus: null
            },
          ]
        },
        {
          menuid: 6,
          icon: 'li-icon-xitongguanli',
          menuname: '系统管理模块',
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 61,
              icon: 'icon-cus-manage',
              menuname: '日志管理',
              hasThird: 'N',
              url: 'system/log',
              menus: null
            },
          ]
        },
      
      ],
      msg: 'success'
    }
          this.allmenu = res.data
    
    menu(localStorage.getItem('logintoken'))
      .then(res => {
        console.log(JSON.stringify(res))
        if (res.success) {
          this.allmenu = res.data
        } else {
          this.$message.error(res.msg)
          return false
        }
      })
      .catch(err => {
        this.$message.error('数据加载失败，请稍后再试！')
      })
    // 监听
    this.$root.Bus.$on('toggle', value => {
      this.collapsed = !value
    })
  }
}
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 305px;
  min-height: 400px;
  /* background-color:rgba(2, 167, 240, 1) !important; */

}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;

}
.el-menu-item-group__title {
  padding: 0px;
}
.el-submenu__title{
   /* background-color:rgba(2, 167, 240, 1) !important;
  color: white;  */
}
.el-submenu__title i {
  /* color: white !important;  */
}
.is-active{
  /* background-color:rgba(2, 167, 240, 1) !important;
  color: white !important; */
}
.el-menu-bg {
  /* background-color: #1f2d3d ;
  background-color:rgba(2, 167, 240, 1) !important; */

}
.el-menu-item{
  /* background-color:#fffff6 !important;
  color: rgba(2, 167, 240, 1) !important; */
}
.el-menu {
  border: none;

}
.el-submenu{
  /* background-color:rgba(2, 167, 240, 1) !important;
  color: white; */
}
.logobox {
  height: 40px;
  line-height: 40px;
  color: #9d9d9d;
  font-size: 20px;
  text-align: center;
  padding: 20px 0px;
  /* background-color:rgba(2, 167, 240, 1);
  color: white; */
}
.logoimg {
  height: 40px;
}
</style>